home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Comm
/
term-source.lha
/
Extras
/
Source
/
term-Source.lha
/
RatePanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-20
|
30KB
|
1,308 lines
/*
** RatePanel.c
**
** Editing panel for phone units configuration
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_TIME=1,GAD_ADDTIME,GAD_REMOVETIME,GAD_EDITTIME,
GAD_PAY1,GAD_MINUTES1,
GAD_PAY2,GAD_MINUTES2,
GAD_LIST,
GAD_ADDDATE,GAD_ADDDAY,GAD_EDIT,
GAD_CLONE,GAD_REMOVE,GAD_IMPORT
};
struct DoubleInfo
{
LONG GlyphWidth,
HeaderLen;
};
/* ListViewRender():
*
* This callback routine is responsible for rendering
* the single listview entries.
*/
STATIC ULONG __saveds __asm
ListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct Node *Node)
{
/* We only know how to redraw lines. */
if(Msg -> lvdm_MethodID == LV_DRAW)
{
struct RastPort *RPort = Msg -> lvdm_RastPort;
LONG Left = Msg -> lvdm_Bounds . MinX,
Top = Msg -> lvdm_Bounds . MinY,
Width = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
Height = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
Delta,
FgPen,BgPen,
Len,LabelLen,Template;
UBYTE *String,Header[8];
struct DoubleInfo *Info;
Info = Hook -> h_Data;
String = &Node -> ln_Name[Info -> HeaderLen];
memcpy(Header,Node -> ln_Name,Info -> HeaderLen);
Header[Info -> HeaderLen] = 0;
/* Determine the rendering pens. */
switch(Msg -> lvdm_State)
{
case LVR_SELECTEDDISABLED:
case LVR_NORMALDISABLED:
case LVR_NORMAL:
FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
break;
case LVR_SELECTED:
FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
break;
}
SetAPen(RPort,BgPen);
RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
Left += 2;
Width -= 2;
/* Set the rendering pens. */
SetDrMd(RPort,JAM2);
SetBPen(RPort,BgPen);
Template = Info -> HeaderLen * Info -> GlyphWidth;
/* Determine header length. */
Len = TextLength(RPort,Header,Info -> HeaderLen);
/* Fill the space to precede the header. */
if((Delta = Template - Len) > 0)
{
SetAPen(RPort,BgPen);
RectFill(RPort,Left,Top,Left + Delta - 1,Top + Height - 1);
}
/* Render the header, right-justified. */
SetAPen(RPort,FgPen);
Move(RPort,Left + Delta,Top + RPort -> Font -> tf_Baseline);
Text(RPort,Header,Info -> HeaderLen);
/* Adjust width and area left edge. */
Left += Template;
Width -= Template;
/* Determine length of vanilla name. */
LabelLen = strlen(String);
/* Try to make it fit. */
while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
LabelLen--;
/* Print the vanilla name if possible. */
if(LabelLen)
{
Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
Text(RPort,String,LabelLen);
Left += Len;
Width -= Len;
}
/* Fill the area to follow the vanilla name. */
if(Width > 0)
{
SetAPen(RPort,BgPen);
RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
}
/* If the item happens to be disabled, draw the cross-hatch
* pattern across it.
*/
if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
{
SetDrMd(RPort,JAM1);
SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
SetAfPt(RPort,(UWORD *)&Ghosting,1);
RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
SetAfPt(RPort,NULL,0);
}
return(LVCB_OK);
}
else
return(LVCB_UNKNOWN);
}
STATIC VOID __regargs
DisableGadgets(struct LayoutHandle *Handle,BOOLEAN Mode,BOOLEAN SetEntries,BOOLEAN SetTime)
{
LT_SetAttributes(Handle,GAD_PAY1,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES1,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_PAY2,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES2,
GA_Disabled, Mode,
TAG_DONE);
if(SetEntries)
{
LT_SetAttributes(Handle,GAD_EDIT,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_CLONE,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVE,
GA_Disabled, Mode,
TAG_DONE);
}
if(SetTime)
{
LT_SetAttributes(Handle,GAD_TIME,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_ADDTIME,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVETIME,
GA_Disabled, Mode,
TAG_DONE);
LT_SetAttributes(Handle,GAD_EDITTIME,
GA_Disabled, Mode,
TAG_DONE);
}
}
BYTE __regargs
RatePanel(struct Window *Parent,struct List *PhoneList,struct PhoneEntry *Entry,struct List *TimeDateList)
{
STATIC struct DoubleInfo TimeInfo;
STATIC struct Hook TimeHook =
{
{NULL},
(HOOKFUNC)ListViewRender,
(HOOKFUNC)NULL,
&TimeInfo
};
STATIC struct DoubleInfo DateInfo;
STATIC struct Hook DateHook =
{
{NULL},
(HOOKFUNC)ListViewRender,
(HOOKFUNC)NULL,
&DateInfo
};
struct LayoutHandle *Handle;
BYTE MadeChanges = FALSE;
if(!TimeDateList)
TimeDateList = (struct List *)&Entry -> TimeDateList;
if(Handle = LT_CreateHandleTags(Parent -> WScreen,
LH_LocaleHook, &LocaleHook,
TAG_DONE))
{
struct Window *PanelWindow;
LONG i,Max = 0,Size;
UBYTE SmallString[2];
SmallString[1] = 0;
for(i = '0' ; i <= '9' ; i++)
{
SmallString[0] = i;
if((Size = LT_LabelWidth(Handle,SmallString)) > Max)
Max = Size;
}
TimeInfo . GlyphWidth = Max;
TimeInfo . HeaderLen = 2;
DateInfo . GlyphWidth = Max;
DateInfo . HeaderLen = 7;
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, HORIZONTAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0156,
TAG_DONE);
{
LT_New(Handle,
LA_Type, LISTVIEW_KIND,
LA_LabelID, MSG_RATEPANEL_TIME_GAD,
LA_Chars, 10,
LA_Lines, 6,
LA_ID, GAD_TIME,
GA_Disabled, TRUE,
GTLV_CallBack, &TimeHook,
LALV_Link, NIL_LINK,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_ADD_TIME_GAD,
LA_ID, GAD_ADDTIME,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_REMOVE_TIME_GAD,
LA_ID, GAD_REMOVETIME,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_EDIT_TIME_GAD,
LA_ID, GAD_EDITTIME,
GA_Disabled, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, HORIZONTAL_KIND,
LA_LabelID, MSG_V36_0157,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_RATEPANEL_FIRST_UNIT_GAD,
TAG_DONE);
{
LT_New(Handle,
LA_Type, INTEGER_KIND,
LA_LabelText, SmallCurrency(),
LA_Chars, 4,
LA_ID, GAD_PAY1,
LAIN_UseIncrementers, TRUE,
LAIN_Min, 0,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, INTEGER_KIND,
LA_LabelID, MSG_RATEPANEL_SECONDS_PER_UNIT_GAD,
LA_ID, GAD_MINUTES1,
LAIN_UseIncrementers, TRUE,
LAIN_Min, 0,
GA_Disabled, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_RATEPANEL_FOLLOWING_UNITS_GAD,
TAG_DONE);
{
LT_New(Handle,
LA_Type, INTEGER_KIND,
LA_LabelText, SmallCurrency(),
LA_Chars, 4,
LA_ID, GAD_PAY2,
LAIN_UseIncrementers, TRUE,
LAIN_Min, 0,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, INTEGER_KIND,
LA_LabelID, MSG_RATEPANEL_SECONDS_PER_UNIT_GAD,
LA_ID, GAD_MINUTES2,
LAIN_UseIncrementers, TRUE,
LAIN_Min, 0,
GA_Disabled, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, LISTVIEW_KIND,
LA_LabelID, MSG_RATEPANEL_DAYS_AND_DATES_GAD,
LA_Chars, 30,
LA_Lines, 10,
LA_ID, GAD_LIST,
GTLV_CallBack, &DateHook,
GTLV_Labels, TimeDateList,
LALV_Link, NIL_LINK,
Kick30 ? TAG_IGNORE : LALV_TextAttr, ~0,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_ADD_DATE_GAD,
LA_ID, GAD_ADDDATE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_ADD_DAYS_GAD,
LA_ID, GAD_ADDDAY,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_EDIT_GAD,
LA_ID, GAD_EDIT,
LABT_ExtraFat, TRUE,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_CLONE_GAD,
LA_ID, GAD_CLONE,
LABT_ExtraFat, TRUE,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_REMOVE_GAD,
LA_ID, GAD_REMOVE,
LABT_ExtraFat, TRUE,
GA_Disabled, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_RATEPANEL_IMPORT_GAD,
LA_ID, GAD_IMPORT,
LABT_ExtraFat, TRUE,
GA_Disabled, !PhoneList,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_RATEPANEL_RATES_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
LAWN_Parent, Parent,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
struct TimeDateNode *TimeDateNode,
*NewNode;
struct List *TimeList = NULL;
LONG Selected = ~0,
Count = 0,
TimeSelected = ~0;
GuideContext(CONTEXT_RATES);
TimeDateNode = (struct TimeDateNode *)TimeDateList -> lh_Head;
while(TimeDateNode -> VanillaNode . ln_Succ)
{
Count++;
TimeDateNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Succ;
}
PushWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
Done = TRUE;
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_TIME:
TimeSelected = MsgCode;
if(Selected != ~0)
{
LT_SetAttributes(Handle,GAD_PAY1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_PAY2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
TAG_DONE);
}
break;
case GAD_EDITTIME:
if(Selected != ~0 && TimeSelected != ~0)
{
UBYTE Time = TimeDateNode -> Table[TimeSelected] . Time;
LT_LockWindow(PanelWindow);
if(TimePanel(&TimeDateNode -> Table[TimeSelected] . Time))
{
struct List *NewTimeList;
MadeChanges = TRUE;
SortTimeTable(TimeDateNode);
if(NewTimeList = BuildTimeList(TimeDateNode))
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, ~0,
TAG_DONE);
if(TimeList)
FreeVecPooled(TimeList);
TimeList = NewTimeList;
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, 0,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
TimeSelected = ~0;
}
else
{
TimeDateNode -> Table[TimeSelected] . Time = Time;
SortTimeTable(TimeDateNode);
DisplayBeep(PanelWindow -> WScreen);
}
}
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
}
break;
case GAD_REMOVETIME:
if(Selected != ~0 && TimeSelected != ~0)
{
MadeChanges = TRUE;
LT_LockWindow(PanelWindow);
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, ~0,
TAG_DONE);
if(DeleteTimeDateNode(TimeDateNode,TimeSelected))
{
if(TimeList)
FreeVecPooled(TimeList);
if(TimeList = BuildTimeList(TimeDateNode))
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, 0,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
TimeSelected = ~0;
}
else
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, &EmptyList,
TAG_DONE);
DisplayBeep(PanelWindow -> WScreen);
}
}
else
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, TimeSelected,
TAG_DONE);
DisplayBeep(PanelWindow -> WScreen);
}
LT_UnlockWindow(PanelWindow);
}
break;
case GAD_ADDTIME:
if(Selected != ~0)
{
UBYTE Time = DT_GET_TIME(12,0);
MadeChanges = TRUE;
LT_LockWindow(PanelWindow);
if(TimePanel(&Time))
{
BYTE AddIt = TRUE;
LONG i;
for(i = 0 ; i < TimeDateNode -> Table[0] . Count ; i++)
{
if(Time == TimeDateNode -> Table[i] . Time)
{
AddIt = FALSE;
break;
}
}
if(AddIt)
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, ~0,
TAG_DONE);
if(ResizeTimeDateNode(TimeDateNode,TimeDateNode -> Table[0] . Count + 1,Time))
{
SortTimeTable(TimeDateNode);
if(TimeList)
FreeVecPooled(TimeList);
if(TimeList = BuildTimeList(TimeDateNode))
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, 0,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
TimeSelected = ~0;
}
else
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, &EmptyList,
TAG_DONE);
DisplayBeep(PanelWindow -> WScreen);
}
}
else
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, TimeSelected,
TAG_DONE);
DisplayBeep(PanelWindow -> WScreen);
}
}
}
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
}
break;
case GAD_PAY1:
TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
MadeChanges = TRUE;
break;
case GAD_PAY2:
TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
MadeChanges = TRUE;
break;
case GAD_MINUTES1:
TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
MadeChanges = TRUE;
break;
case GAD_MINUTES2:
TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
MadeChanges = TRUE;
break;
case GAD_LIST:
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels,~0,
TAG_DONE);
if(TimeList)
FreeVecPooled(TimeList);
TimeDateNode = (struct TimeDateNode *)GetListNode(MsgCode,(struct List *)TimeDateList);
if(TimeList = BuildTimeList(TimeDateNode))
{
TimeSelected = 0;
Selected = MsgCode;
DisableGadgets(Handle,FALSE,FALSE,FALSE);
TimeDateNode = (struct TimeDateNode *)GetListNode(Selected,(struct List *)TimeDateList);
LT_SetAttributes(Handle,GAD_PAY1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_PAY2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, 0,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_ADDTIME,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVETIME,
GA_Disabled, TimeDateNode -> Table[0] . Count < 2,
TAG_DONE);
LT_SetAttributes(Handle,GAD_EDITTIME,
GA_Disabled, FALSE,
TAG_DONE);
if(Selected)
{
LT_SetAttributes(Handle,GAD_EDIT,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_CLONE,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVE,
GA_Disabled, FALSE,
TAG_DONE);
}
else
{
LT_SetAttributes(Handle,GAD_EDIT,
GA_Disabled, TRUE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_CLONE,
GA_Disabled, TRUE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVE,
GA_Disabled, TRUE,
TAG_DONE);
}
}
else
{
TimeDateNode = NULL;
DisplayBeep(PanelWindow -> WScreen);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, &EmptyList,
GTLV_Selected, ~0,
GA_Disabled, TRUE,
TAG_DONE);
TimeSelected = ~0;
}
break;
case GAD_IMPORT:
LT_LockWindow(PanelWindow);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
MadeChanges |= ImportPanel(Entry,PhoneList,TimeDateList);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
TimeSelected = ~0;
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
break;
case GAD_ADDDAY:
case GAD_ADDDATE:
LT_LockWindow(PanelWindow);
MadeChanges = TRUE;
if(NewNode = CreateTimeDateNode(0,1,"",2))
{
BYTE Result;
if(MsgGadget -> GadgetID == GAD_ADDDAY)
{
NewNode -> Header . Month = -1;
NewNode -> Header . Day = 0;
Result = DayPanel(NewNode);
}
else
Result = DatePanel(NewNode);
if(Result)
{
AdaptTimeDateNode(NewNode);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
AddTail((struct List *)TimeDateList,&NewNode -> VanillaNode);
Selected = Count++;
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, Selected,
GTLV_Top, Selected,
GTLV_MakeVisible, Selected,
TAG_DONE);
TimeDateNode = NewNode;
Redisplay: if(TimeList)
FreeVecPooled(TimeList);
if(TimeList = BuildTimeList(TimeDateNode))
{
if(TimeSelected == ~0)
TimeSelected = 0;
DisableGadgets(Handle,FALSE,TRUE,FALSE);
LT_SetAttributes(Handle,GAD_PAY1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES1,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_PAY2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_MINUTES2,
GTIN_Number, TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
TAG_DONE);
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, TimeSelected,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_ADDTIME,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_REMOVETIME,
GA_Disabled, TimeDateNode -> Table[0] . Count < 2,
TAG_DONE);
LT_SetAttributes(Handle,GAD_EDITTIME,
GA_Disabled, FALSE,
TAG_DONE);
LT_Activate(Handle,GAD_PAY1);
}
else
{
TimeDateNode = NULL;
DisplayBeep(PanelWindow -> WScreen);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
LT_SetAttributes(Handle,GAD_TIME,
GA_Disabled, FALSE,
GTLV_Selected, 0,
TAG_DONE);
TimeSelected = ~0;
}
}
else
FreeVecPooled(NewNode);
}
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
break;
case GAD_REMOVE:
if(--Count)
{
if(TimeDateNode -> VanillaNode . ln_Succ -> ln_Succ)
NewNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Succ;
else
{
NewNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Pred;
TimeSelected--;
}
}
MadeChanges = TRUE;
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
Remove(TimeDateNode);
FreeVecPooled(TimeDateNode);
if(Count > 1)
{
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, Count,
TAG_DONE);
TimeDateNode = NewNode;
goto Redisplay;
}
else
{
DisableGadgets(Handle,TRUE,TRUE,FALSE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
TimeDateNode = NULL;
}
break;
case GAD_CLONE:
if(NewNode = CreateTimeDateNode(0,1,"",TimeDateNode -> Table[0] . Count))
{
MadeChanges = TRUE;
strcpy(NewNode -> VanillaNode . ln_Name = NewNode -> Buffer,TimeDateNode -> Buffer);
NewNode -> Header = TimeDateNode -> Header;
CopyMem(TimeDateNode -> Table,NewNode -> Table,sizeof(struct TimeDate) * TimeDateNode -> Table[0] . Count);
AdaptTimeDateNode(NewNode);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
AddTail((struct List *)TimeDateList,&NewNode -> VanillaNode);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, Count++,
TAG_DONE);
TimeDateNode = NewNode;
goto Redisplay;
}
break;
case GAD_EDIT:
LT_LockWindow(PanelWindow);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
if(TimeDateNode -> Header . Month == -1)
MadeChanges |= DayPanel(TimeDateNode);
else
MadeChanges |= DatePanel(TimeDateNode);
AdaptTimeDateNode(TimeDateNode);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, Selected,
TAG_DONE);
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
break;
}
}
if(MsgClass == IDCMP_IDCMPUPDATE)
{
switch(MsgGadget -> GadgetID)
{
case GAD_TIME:
if(Selected != ~0 && TimeSelected != ~0)
{
UBYTE Time = TimeDateNode -> Table[TimeSelected] . Time;
LT_PressButton(Handle,GAD_EDITTIME);
LT_LockWindow(PanelWindow);
if(TimePanel(&TimeDateNode -> Table[TimeSelected] . Time))
{
struct List *NewTimeList;
MadeChanges = TRUE;
SortTimeTable(TimeDateNode);
if(NewTimeList = BuildTimeList(TimeDateNode))
{
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, ~0,
TAG_DONE);
if(TimeList)
FreeVecPooled(TimeList);
TimeList = NewTimeList;
LT_SetAttributes(Handle,GAD_TIME,
GTLV_Labels, TimeList,
GTLV_Selected, 0,
GA_Disabled, FALSE,
TAG_DONE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
DisableGadgets(Handle,TRUE,TRUE,TRUE);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, ~0,
TAG_DONE);
Selected = ~0;
TimeSelected = ~0;
}
else
{
TimeDateNode -> Table[TimeSelected] . Time = Time;
SortTimeTable(TimeDateNode);
DisplayBeep(PanelWindow -> WScreen);
}
}
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
}
break;
case GAD_LIST:
if(Selected != ~0 && Selected > 0)
{
LT_PressButton(Handle,GAD_EDIT);
LT_LockWindow(PanelWindow);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, ~0,
TAG_DONE);
if(TimeDateNode -> Header . Month == -1)
MadeChanges |= DayPanel(TimeDateNode);
else
MadeChanges |= DatePanel(TimeDateNode);
AdaptTimeDateNode(TimeDateNode);
LT_SetAttributes(Handle,GAD_LIST,
GTLV_Labels, TimeDateList,
GTLV_Selected, Selected,
TAG_DONE);
LT_UnlockWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
break;
}
break;
}
}
}
}
while(!Done);
PopWindow();
if(TimeList)
FreeVecPooled(TimeList);
}
LT_DeleteHandle(Handle);
}
return(MadeChanges);
}